//
//  CommonTool.m
//  birthdayCalculate
//
//  Created by 宋浩文的pro on 15/12/18.
//  Copyright © 2015年 宋浩文的pro. All rights reserved.
//

#import "CommonTool.h"
#import "MBProgressHUD.h"


@implementation CommonTool



+ (void)showHUDWillDismissText:(NSString *)text withTime:(NSUInteger)time
{
    UIWindow *window = [[UIApplication sharedApplication].windows firstObject];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
    hud.labelText = text;
    [hud hide:YES afterDelay:time];
    hud.mode = MBProgressHUDModeText;
}


+ (void)showOneChoice:(NSString *)choice message:(NSString *)message from:(UIViewController *)viewController
{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:choice style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        
    }];
    
    [alertController addAction:action];
    [viewController presentViewController:alertController animated:YES completion:nil];
    
}


+ (void)showError:(NSString *)info
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:Window animated:YES];
    
    hud.mode = MBProgressHUDModeCustomView;
    UIImage *image = [UIImage imageNamed:@"error"];
    hud.customView = [[UIImageView alloc] initWithImage:image];
    
    hud.labelText = info;
    
    [hud hide:YES afterDelay:2];
}

+ (void)showSuccess:(NSString *)info
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:Window animated:YES];
    
    hud.mode = MBProgressHUDModeCustomView;
    UIImage *image = [UIImage imageNamed:@"success"];
    hud.customView = [[UIImageView alloc] initWithImage:image];
    hud.square = YES;
    hud.labelText = info;
    
    [hud hide:YES afterDelay:2];
}






@end
